import {HttpClient} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {Observable} from "rxjs/Observable";
import {ClientProspectiveModel} from "../../../model/pages/client/client-prospective/client-prospective.model";
import "rxjs/add/observable/of";
import {PageParamsModel} from "../../../model/common/page-params.model";


//   准客户


@Injectable()
export class ClientProspectiveProvider {
    data = {
        "list": [
            {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": [{"phone": ""}],// 电话号码
                "name": "头像1",// 姓名
                "sex": "F", //性别
                "source": "手动新增",// 新增字段，客户来源
                "age": "56",
            },
            {
                "birthDate": "2017-02-10", //生日
                "clientId": "2", //客户ID
                "mobileList": [{"phone": "13134648242"}],// 电话号码
                "name": "头像1",// 姓名
                "sex": "F", //性别
                "source": "手动新增",// 新增字段，客户来源
                "age": "56",
            },
            {
                "birthDate": "2017-02-10", //生日
                "clientId": "0", //客户ID
                "mobileList": [],// 电话号码
                "name": "头像1",// 姓名
                "sex": "M", //性别
                "source": "手动新增",// 新增字段，客户来源
                "age": "56",
            },
            {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": null,// 电话号码
                "name": "头像1",// 姓名
                "sex": "F", //性别
                "source": "0",// 新增字段，客户来源
                "age": "56",
            },
            {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": "",// 电话号码
                "name": "头像1",// 姓名
                "sex": "0", //性别
                "source": "手动新增",// 新增字段，客户来源
                "age": "56",
            },
            {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": [{"phone": "13134648242"}],// 电话号码
                "name": "头像1",// 姓名
                "sex": "F", //性别
                "source": "0",// 新增字段，客户来源
                "age": "56",
            }, {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": [{"phone": "13134648242"}],// 电话号码
                "name": "头像1",// 姓名
                "sex": "M", //性别
                "source": "手动新增",// 新增字段，客户来源
                "age": "56",
            }, {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": [{"phone": "13134648242"}],// 电话号码
                "name": "头像1",// 姓名
                "sex": "M", //性别
                "source": "手动新增",// 新增字段，客户来源
                "age": "56",
            }, {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": [{"phone": "13134648242"}],// 电话号码
                "name": "头像1",// 姓名
                "sex": "F", //性别
                "source": "手动新增",// 新增字段，客户来源
                "age": "56",
            }, {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": [{"phone": "13134648242"}],// 电话号码
                "name": "头像1",// 姓名
                "sex": "", //性别
                "source": "手动新增",// 新增字段，客户来源
                "age": "56",
            }, {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": [{"phone": "13134648242"}],// 电话号码
                "name": "头像1",// 姓名
                "sex": "F", //性别
                "source": "0",// 新增字段，客户来源
                "age": "56",
            }, {
                "birthDate": "2017-02-10", //生日
                "clientId": "1", //客户ID
                "mobileList": [{"phone": "13134648242"}],// 电话号码
                "name": "头像1",// 姓名
                "sex": "M", //性别
                "source": "0",// 新增字段，客户来源
                "age": "56",
            },


        ]
    };

    constructor(public http: HttpClient) {

    }

    /**
     * 获取准客户
     * @returns {any}
     */
    getClientList(notLoading = 0, pageParams: PageParamsModel): Observable<any> {
        //  return Observable.of(this.data);
        return this.http.get(`/leads/v1/leads`, {
       // return this.http.get(`http://10.248.37.233:8802/leads/v1/leads`, {
            params: {
                keywords: pageParams.condition.keyword ? pageParams.condition.keyword : '',
                pageNum: '' + pageParams.pageNum,
                pageSize: '' + pageParams.pageSize
            }
        });
    }

    getAllProspect(keyWord?: string,notLoading=0,notLoadingNow=0): Observable<any> {

       return this.http.get(`/leads/v1/list/leads`, {
       // return this.http.get(`http://10.248.37.62:8065/leads/v1/list/leads`, {
                params: {
                    keywords: keyWord ? keyWord : ''
                }
            }
        );

    }

}
